function coef = ajpoly(x,y,p,ordem)
    n = ordem+1;
    A = zeros(n);
    for i = 1:n
        for j = 1:n
            A(i,j) = sum( x.^((i-1)+(j-1)) );
        end
    end
    A(1,1) = p;
    b = zeros(ordem,1);
    for i = 1:n
        b(i,1) = sum( y.*(x.^(i-1)) );
    end
    coef = inv(A)*b;